<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
	pageEncoding="ISO-8859-1"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<%@ taglib prefix="sj" uri="/struts-jquery-tags"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<sj:head/>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>EVON Global Logistics Solution</title>
<link href="css/style.css" rel="stylesheet" type="text/css" />
<script type="text/javascript">
	//document.getElementById("hiddenButton").style.display = "none";

	//function editYardDetails(val) {
		//document.getElementById("hidYardId").value = val;
		//document.forms["showYard"].action = 'yardDetail';
		//document.forms["showYard"].submit();
		//alert (value);
	//}

	function fnSubmitAction() {
		document.forms["showYard"].action = 'submit';
		document.forms["showYard"].submit();
	}

	function fnSetYardType(val) {
		alert(val);
		//document.getElementById("yardType").value = val;
	}

	function fnClearYardDetail() {
		//alert(val);
		//document.getElementById("newYard").value = true;
		document.getElementById("hidYardId").value = '';
		document.getElementById("hidNewYard").value = '';
		document.getElementById("hidActiveCheckInd").value = '';
		document.getElementById("yardName").value = '';
		document.getElementById("yardAddress").value = '';
		document.getElementById("yardCity").value = '';
		document.getElementById("yardPhone").value = '';
		document.getElementById("isActive").checked = false;
	}

	function fnShowSection() {
		document.forms["showYard"].action = 'manageAllSections';
		document.forms["showYard"].submit();
	}

	function fnCreateSection() {
		document.forms["showYard"].action = 'manageSection';
		document.forms["showYard"].submit();
	}

	function fnShowKeyBins() {
		document.forms["showYard"].action = 'manageAllKeyBins';
		document.forms["showYard"].submit();
	}

	function fnDisableOEM(obj) {
		if (obj.value == "P"){
			document.getElementById("oemType").disabled = true;
			} else {
				document.getElementById("oemType").disabled = false;
			}
				
	}
	function confirmActive(obj) {
		if ("new" != document.getElementById("hidNewYard").value){
		var msg = "";
		if (obj.checked) {
			msg = "Are you sure to Activate";
		} else {
			msg = "Are you sure to Deactivate";
		}
		var r = confirm(msg)
		if (r == false) {
			if (obj.checked) {
				document.getElementById("isActive").checked = false;
				} else {
					document.getElementById("isActive").checked = true;
				}
			//document.getElementById("isActive").value = false;
			//alert("cancel");
		} else if (r == true) {
			
		//	document.forms["showYard"].action = 'manageActive';
		//	document.forms["showYard"].submit();

		}
		}
	}
</script>
</head>

<body>
<sj:div id="manageYardInnerDiv" name="manageYardInnerDiv">


	
	<s:form action="manageYard" name="showYard" id="showYard" theme="simple" validate="true">
	

	
	<h4>
<s:actionmessage/>
<s:fielderror></s:fielderror>

</h4>

	
	<table width="99%" border="0" align="center" cellpadding="4"
		cellspacing="1" class="gridtable">
		<tr>
			<th colspan="4">Enter Details</th>
		</tr>
		<tr class="alt">
			<td width="15%">Select Country</td>
			<td width="35%">

			<table cellpadding="" cellspacing="">
				<tr>
				<tr>
					<td><s:select name="country" list="countryList"
						listKey="countryCode" listValue="countryName" headerKey="0"
						headerValue="Select Country">
						</s:select></td>
						</tr>
						<tr>
					<td>
						<s:radio  theme="simple" name="yardType" list="listYardType" onclick="fnDisableOEM(this)" />
					</td>
					</tr>
				</tr>
			</table>

			</td>
			<td>Select OEM</td>
			<td>
			<table cellpadding="" cellspacing="">
				<tr>
					<td><s:select id = "oemType" name="oemType" list="oemList" listKey="oemId"
						listValue="oemName" headerKey="0" headerValue="Select OEM"
						onchange="$.publish('showYardTopic')">
						</s:select>
					</td>
					<s:url var="populateYardUrl" action="manageYard" ></s:url>
	
						<sj:div id = "hiddenButton" cssStyle="display:none;">
							<sj:submit  formIds="showYard"  href = "%{populateYardUrl}" listenTopics="showYardTopic" targets="manageYardInnerDiv">
							</sj:submit>
						</sj:div>
						
					<td>
						<s:iterator value="availableYard">
							<s:radio id='%{yardId}' name="selectedYard" list='%{name}'
								onclick="$.publish('yardDetailTopic')">
							</s:radio>
						
						</s:iterator>
					</td>
				</tr>
				<s:url var="populateyarddetailUrl" action="yardDetail" >
				</s:url>
		
				<sj:div id = "hiddebButton" cssStyle="display:none;">
					<sj:submit  formIds="showYard"  href = "%{populateyarddetailUrl}" listenTopics="yardDetailTopic" targets="manageYardInnerDiv"></sj:submit>
				</sj:div>
				<s:url id="url" value="/execute.action" />
				<s:hidden id="hidYardId" name="yardDetail.id" value="%{yardDetail.id}" />
				<s:hidden id="hidNewYard" name="hidNewYard" value="%{hidNewYard}" /> 
				<!--<s:hidden id="hidActiveCheckInd" name="hidActiveCheckInd" value="" />-->
			</table>
			</td>
		</tr>
		<tr class="alt">
			<td>Yard Name</td>
			<td><s:textfield id="yardName" name="yardDetail.name"
				label="YardName" value='%{yardDetail.name}' maxlength="50"/></td>
			<td>Yard Address</td>
			<td><s:textfield id="yardAddress" name="yardDetail.address"
				label="YardAddress" value="%{yardDetail.address}" /></td>
		</tr>
		<tr class="alt">
			<td>City</td>
			<td><s:textfield id="yardCity" name="yardDetail.city"
				label="City" value="%{yardDetail.city}" maxlength="30" /></td>
			<td>Phone Number</td>
			<td><s:textfield id="yardPhone" name="yardDetail.phone"
				label="Phone" value="%{yardDetail.phone}" maxlength="13"/></td>
		</tr>
		
		<tr class="alt">
			<td>Active</td>
			<td><s:checkbox id="isActive" name="yardDetail.isActive"
				label="Active" value="%{yardDetail.isActive}" onclick="confirmActive(this)"
				></s:checkbox></td>

		</tr>
		
	</table>
	
	<table width="99%" border="0" align="center" cellpadding="0"
		cellspacing="0">
		<tr>
			<td style="height: 10px;"></td>
		</tr>
		<tr>
			<td align="right">
				<sj:submit targets= "manageYardInnerDiv" formIds="showYard" href="submit.action" 
				cssClass="btnbg" /></td>
		</tr>
	</table>

	
	
	</s:form>
</sj:div>
</body>
</html>
